#pragma once
#include"RBTree.h"
namespace yxt
{
	template<class K,class V>
	class map
	{
		typedef pair<const K, V> Val;
		struct MapOfKey
		{
			K operator()(const Val& ret)
			{
				return ret.first;
			}
		};
		typedef RBTree<K, Val, MapOfKey> RBTree;
		RBTree _map;
	public:
		typedef typename RBTree::iterator iterator;
		typedef typename RBTree::const_iterator const_iterator;
		pair<iterator,bool> insert(const Val& ret)
		{
			return _map.insert(ret);
		}
		iterator begin()
		{
			return _map.begin();
		}
		iterator end()
		{
			return _map.end();
		}
		V& operator[](const K& tem)
		{
			pair<iterator, bool> ret = _map.insert(make_pair(tem, V()));
			return ret.first->second;
		}
	};

};
